# $Id: admin.py 14 2008-08-21 21:31:25Z jkingry $

import os
from google.appengine.ext.webapp import template
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

from mithril.data import *

#-----------------------------------
class DefaultHandler(webapp.RequestHandler):
  def get(self):    
    servers_query = AppServer.all().order('-created')
    
    template_values = {
      'servers': servers_query.fetch(10),
      'account': current_account(),
      'logout_url': users.create_logout_url("/")
    }
    
    path = os.path.join(os.path.dirname(__file__), 'admin.html')
    self.response.out.write(template.render(path, template_values))
#-----------------------------------

application = webapp.WSGIApplication(
                                     [
                                      ('/admin', DefaultHandler)
                                     ],
                                     debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()